﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WPF60.Infrastructure.Model;
using WPF60.Infrastructure.Utility;

namespace WPF60.Infrastructure.Services
{
    public interface IDemoPageProvider
    {
        DemoPage[] LoadDemoPages();
    }

    public class DemoPageProvider : IDemoPageProvider
    {
        public DemoPage[] LoadDemoPages()
        {
            var pages = System.IO.File.ReadAllLines("Pages.txt");

            var list = new List<DemoPage>();

            pages.ForEach(s =>
                              {
                                  if (!s.StartsWith("#"))
                                  {
                                      var splits = s.Split('\t');

                                      if (splits.Count() > 1)
                                      list.Add(
                                          new DemoPage()
                                              {
                                                  Name = splits[1],
                                                  PresenterClassName = splits[0]
                                              }
                                          );
                                  }
                              });

            return list.ToArray();
        }

    }
}
